home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / E-G / Externals.cpt / Externals / card_8200.txt < prev    next >
Text File  |  1989-02-26  |  4KB  |  103 lines

  1. -- card: 8200 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2795
  5. -- name: Find
  6.  
  7.  
  8. -- part 1 (button)
  9. -- low flags: 00
  10. -- high flags: 8003
  11. -- rect: left=316 top=307 right=329 bottom=380
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: Demo
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   visual effect iris open
  23.   go to card id 9227
  24. end mouseUp
  25.  
  26.  
  27.  
  28. -- part contents for background part 1
  29. ----- text -----
  30. XFCN
  31.  
  32. -- part contents for background part 22
  33. ----- text -----
  34. Find(containerName,[<]string[,startLine,startItem])
  35.  
  36. -- part contents for background part 13
  37. ----- text -----
  38.    Find - finds a string in a container returning line & item number
  39.  
  40. containerName can be a field or variable with lines of data where each line consists of items.
  41. If the string is not immediately preceeded by "<", then there must be an exact item match.
  42. A starting line and item may optionally be specified and the search will begin in the next item.
  43. The function returns the line and item number of the match as an ordered pair.
  44. 0,0 indicates that no match was found.
  45. The match does take into consideration upper and lower case
  46.  
  47. This routine is not public domain. If you use it in your own stacks, you must send in a $10 license fee to:
  48.                             Boojum Computer Systems, Inc.
  49.                             15004 Donna Drive
  50.                             Silver Spring, Md 20904
  51.  
  52. Copyright 1987 Boojum Computer Systems, Inc.       All Right Reserved
  53.  
  54. --Find Script for Find Demo
  55. on mouseUp
  56.   global source, lastPos, match    -- match is either empty (excact) or "<" (partial)
  57.   put empty into card field "searchF"
  58.   set the scroll of card field "names" to 0
  59.   set the hilite of button "hiliteRegion" to false
  60.   ask "Find what state or capitol?" with source  --get the search string
  61.   if it is not empty then
  62.     put it into source
  63.     put find( card field "names", match & source ) into lastPos
  64.     if item 1 of lastPos=0 then       -- item not found
  65.       put empty into card field "lineF"
  66.       put empty into card field "itemF"
  67.       put "Search string not found" into card field "searchF"
  68.       set the hilite of button "hiliteRegion" to false
  69.     else
  70.       put "Line"&&item 1 of lastPos into card field "lineF"   -- item is found
  71.       put "Item"&&item 2 of lastPos into card field "itemF"
  72.       put "Search string found in:" into card field "searchF"
  73.       put (the textHeight of card field "names")*¬¨
  74.       (item 1 of lastPos - 1) into scrollAmount
  75.       set the scroll of card field "names" to scrollAmount     --scroll to the correct line
  76.       set the hilite of button "hiliteRegion" to true      --hilite the line with invisible button
  77.     end if
  78.   end if
  79. end mouseUp
  80.  
  81. --Next Find Script
  82. on mouseUp
  83.   global lastPos, source, match
  84.   put empty into card field "searchF"
  85.   put find( card field "names", match & source, item 1 of lastPos,¬¨
  86.   item 2 of lastPos ) into lastPos
  87.   if item 1 of lastPos=0 then
  88.     put empty into card field "lineF"
  89.     put empty into card field "itemF"
  90.     put "Search string not found" into card field "searchF"
  91.     set the hilite of button "hiliteRegion" to false
  92.   else
  93.     put "Line"&&item 1 of lastPos into card field "lineF"
  94.     put "Item"&&item 2 of lastPos into card field "itemF"
  95.     put "Search string found in:" into card field "searchF"
  96.     put (the textHeight of card field "names")*¬¨
  97.     (item 1 of lastPos - 1) into scrollAmount
  98.     set the scroll of card field "names" to scrollAmount
  99.     set the hilite of button "hiliteRegion" to true
  100.   end if
  101. end mouseUp
  102.  
  103.